package com.education.wisdom.controller.app;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.education.common.core.BaseController;
import com.education.common.utils.LogUtil;
import com.education.common.utils.StringUtils;
import com.education.common.utils.UUIDUtils;
import com.education.wisdom.pojo.*;
import com.education.wisdom.service.IAnswersService;
import com.education.wisdom.service.IPaperService;
import com.education.wisdom.service.IQuestionsService;
import com.education.wisdom.service.JrAnswTwoService;
import com.education.wisdom.vo.QuestionsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.*;


/**
 * 试题 信息操作处理
 *
 * @author ruoyi
 * @date 2018-11-13
 */
@Controller
@CrossOrigin
@Slf4j
@Api(tags = {"试题 信息操作处理"})
@RequestMapping("/appQuestions")
public class AppQuestionsController extends BaseController {
    private String prefix = "system/questions";

    @Autowired
    private IQuestionsService questionsService;

    @Autowired
    private IAnswersService answersService;

    @Autowired
    private JrAnswTwoService jrAnswTwoService;

    @Autowired
    private IPaperService paperService;

    @GetMapping()
    public String questions() {
        return prefix + "/questions";
    }

    @GetMapping("/answerRecord")
    public void answerRecord(HttpServletResponse response, String userId, Integer id) throws IOException {
        int j = 0;
        log.info(LogUtil.LogInfo("查询答题记录", new Date()));
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("userId", userId);
        Answers answers = answersService.selectByPaperId(map);
        if (answers != null) {
            Paper paper = paperService.selectPaperById(answers.getDjPaperid());
            String djContent = answers.getDjContent();
            String[] split = djContent.split(",");
            String[] o = answersService.selectByIds(split);
            List<Questions> list = questionsService.selectByPaperId(id);
            for (int i = 0; i < list.size(); i++) {
                list.get(i).setXsAnswer(o[j].toString());
                j++;
                list.get(i).setStCteater(paper.getSjIntroduction());
            }
            Map<String, Object> resu = resu(list);
            resu.put("fenshu", answers.getDjScore());
            resu.put("zongfen", paper.getSjScore());
            writeJSON(resu, response, "200", "成功");
        }
    }

    //筛选题型
    public Map<String, Object> resu(List<Questions> list) {
        HashMap<String, Object> map = new HashMap<>();
        List<Questions> dx = new ArrayList<>();
        List<Questions> duox = new ArrayList<>();
        List<Questions> pd = new ArrayList<>();
        List<Questions> jd = new ArrayList<>();
        Iterator<Questions> iterator = list.iterator();
        //1 单选 2 判断 3 多选 4 简答
        while (iterator.hasNext()) {
            Questions q = iterator.next();
            switch (q.getQuestionType()) {
                case "1":
                    dx.add(q);
                    break;
                case "2":
                    pd.add(q);
                    break;
                case "3":
                    duox.add(q);
                    break;
                case "4":
                    jd.add(q);
                    break;
            }
        }
        map.put("danxuan", dx);
        map.put("panduan", pd);
        map.put("duoxuan", duox);
        map.put("jianda", jd);
        return map;
    }


    /**
     * 查询试题列表
     */
    @ApiOperation("试题信息")
    @GetMapping("/questionsList")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "paperId", value = "试卷编号", required = true, dataType = "String")

    })
    public void questionsList(HttpServletResponse response, HttpServletRequest request, String paperId) throws Exception {
        log.info(LogUtil.LogInfo("查询试题列表", new Date()));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("paperId", paperId);
        List<QuestionsVo> list = questionsService.selectQuestionsListById(map);//根据paperId查询试题
        Integer count = questionsService.selectCount(map);//试题总数
        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("count", count);
        map1.put("list", list);
        writeJSON(map1, response, "200", "成功");
    }

    /**
     * 查询我的测试列表接口
     *//*
	@ApiOperation("试题信息")
	@GetMapping("/testList")
	@ResponseBody
	@ApiImplicitParams({
			@ApiImplicitParam(name="paperId",value="试卷编号",required=true,dataType="String")
	})
	public void testList(HttpServletResponse response, HttpServletRequest request, String djUserid)throws Exception{
		Answers answers1 = new Answers();
		answers1.setDjUserid(djUserid);
		ArrayList<Answers> list = new ArrayList<>();
		List<Answers> answers = answersService.selectAnswersList(answers1);
		for (Answers answer : answers) {
			Integer djPaperid = answer.getDjPaperid();
			SimpleDateFormat dateForma = new SimpleDateFormat("yyyy-MM-dd HH:mm");

			//做题时间
			Date djStarttime = answer.getDjStarttime();
			Date djEndtime = answer.getDjEndtime();
			long l = djEndtime.getTime() - djStarttime.getTime();
			String s = (l / (1000 * 60)) + "";
			answer.setQuestionTime(s);

			String format = dateForma.format(djStarttime);
			answer.setStartTime(format);
			Paper paper = paperService.selectPaperById(djPaperid);
			if(paper != null){
				String sjIntroduction = paper.getSjIntroduction();
				answer.setName(sjIntroduction);
				list.add(answer);
			}
		}
		writeJSON(list,response,"200","success");
	}*/

    /**
     * 查询我的测试列表接口
     */
    @ApiOperation("试题信息")
    @GetMapping("/testList")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "paperId", value = "试卷编号", required = true, dataType = "String")
    })
    public void testList(HttpServletResponse response, HttpServletRequest request, String djUserid) throws Exception {
        List<Paper> list = paperService.selectVocationalSkillTest1(djUserid);
        for (Paper paper : list) {
            Date djStarttime = paper.getDjStarttime();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            String s1 = dateFormat.format(djStarttime);
            paper.setTime(s1);
            Date djEndtime = paper.getDjEndtime();
            long l = djEndtime.getTime() - djStarttime.getTime();
            String s = (l / (1000 * 60)) + "";
            paper.setYonshi(Long.valueOf(s));
        }
		/*for (Paper paper : list) {
			Map<String, Object> map = new HashMap<>();
			map.put("id", paper.getId());
			map.put("userId", djUserid);
			List<Answers> answers = answersService.selectByPaperId3(map);
			for (Answers answer : answers) {

				//Date djStarttime = answer.getDjStarttime();
				paper.setDjStarttime(answer.getDjStarttime());
				paper.setDjEndtime(answer.getDjEndtime());
				long l = paper.getDjEndtime().getTime() - paper.getDjStarttime().getTime();
				long nd = 1000 * 24 * 60 * 60;
				long nh = 1000 * 60 * 60;
				long nm = 1000 * 60;
				long min = l % nd % nh / nm;
				paper.setYonshi(min);
				paper.setDefen(answer.getDjScore().toString());

				Date starttime = paper.getDjStarttime();
				SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				String format = dateFormat.format(starttime);
				paper.setTime(format);

				Integer paperId = paper.getId();
				answer.setDjPaperid(paperId);
				answer.setDjUserid(djUserid);
				List<Answers> list1 = answersService.selectAnswersList(answer);
				for (Answers answers1 : list1) {
					String djId = answers1.getDjId();
					paper.setDjId(djId);
				}
			}
		}*/
        writeJSON(list, response, "200", "成功");
    }

    /*
     */
/**
 * 查询所有试题及类型
 *//*

	@ApiOperation("试题类型信息列表")
	@GetMapping("/questionanswer")
	@ResponseBody
	public void questionanswer(HttpServletResponse response, HttpServletResponse request, Integer paperId, String djId)throws Exception{
		log.info(LogUtil.LogInfo("查询试题列表",new Date()));
		List<Questions> questions1 = questionsService.selectByPaperId(paperId);
		Integer i=0;
		//计算总分数
		BigDecimal b0 = new BigDecimal(0);
		for (Questions questions : questions1) {
			BigDecimal stScore = questions.getStScore();
			b0 = b0.add(new BigDecimal(String.valueOf(stScore)));


		}
		//Answers answers = answersService.selectAnswersById(djId);
		List<Answers> answers = answersService.selectByPaperId1(paperId);
		//Answers answers1 = answers.get(answers.size()-1);
		for (Answers answer : answers) {

			BigDecimal djScore = answer.getDjScore();
			String djContent = answer.getDjContent();
			String[] split = djContent.split(",");
			for (String s : split) {
				JrAnswTwo jrAnswTwo = jrAnswTwoService.selectJrAnswTwoById(Integer.valueOf(s));
				Questions questions = questions1.get(i);
				questions.setXsAnswer(jrAnswTwo.getText());
				i++;

			}
			HashMap<Object, Object> map = new HashMap<>();
			ArrayList<Questions> list = new ArrayList<>();
			ArrayList<Questions> list1 = new ArrayList<>();
			ArrayList<Questions> list2 = new ArrayList<>();
			ArrayList<Questions> list3 = new ArrayList<>();

			for (Questions questions : questions1) {
				if("1".equals(questions.getQuestionType())){
					list.add(questions);
				}else if("2".equals((questions.getQuestionType()))){
					list1.add(questions);
				}else if("3".equals(questions.getQuestionType())){
					list2.add(questions);
				}else if("4".equals(questions.getQuestionType())){
					list3.add(questions);
				}
			}
			map.put("fenshu",djScore);
			map.put("zongfen",b0);
			map.put("danxuan", list);
			map.put("panduan", list1);
			map.put("duoxuan", list2);
			map.put("jianda", list3);
			writeJSON(map,response,"200","成功");
		}

	}
*/

    /**
     * 查询所有试题及类型
     */
    @ApiOperation("试题类型信息详情")
    @GetMapping("/questionanswer")
    @ResponseBody
    public void questionanswer(HttpServletResponse response, HttpServletResponse request, Integer paperId, String djId) throws Exception {
        log.info(LogUtil.LogInfo("查询试题详情", new Date()));
        Answers answers1 = answersService.selectAnswersById(djId);
        Integer djPaperid = answers1.getDjPaperid();
        //根据paperID得到试题列表
        List<Questions> questions1 = questionsService.selectByPaperId(djPaperid);

        Integer i = 0;
//        //计算总分数
//        BigDecimal b0 = new BigDecimal(0);
//        for (Questions questions : questions1) {
//            BigDecimal stScore = questions.getStScore();
//            b0 = b0.add(new BigDecimal(String.valueOf(stScore)));
//        }
        Paper paper = paperService.selectPaperById(djPaperid);
        Integer single = StringUtils.isNotNull(paper.getSingle()) ? paper.getSingle() : 0;//单选题个数 10
        String singleScore = StringUtils.isNotNull(paper.getSingleScore()) ? paper.getSingleScore() : "0";//单选题分数10
        Integer many = StringUtils.isNotNull(paper.getMany()) ? paper.getMany() : 0;//多选题个数//0
        String manyScore = StringUtils.isNotNull(paper.getManyScore()) ? paper.getManyScore() : "0";//多选题分数10
        Integer judgment = StringUtils.isNotNull(paper.getJudgment()) ? paper.getJudgment() : 0;//判断题个数1
        String judgmentScore = StringUtils.isNotNull(paper.getJudgmentScore()) ? paper.getJudgmentScore() : "0";//判断题分数10
        Integer answ = StringUtils.isNotNull(paper.getAnsw()) ? paper.getAnsw() : 0;//null
        String answSore = StringUtils.isNotNull(paper.getAnswSore()) ? paper.getAnswSore() : "0";//0
        //single 10 singleScore 10
        int b0 = single * Integer.parseInt(singleScore) + many * Integer.parseInt(manyScore) + judgment * Integer.parseInt(judgmentScore) + answ * Integer.parseInt(answSore);

        BigDecimal djScore = answers1.getDjScore();
        String djContent = answers1.getDjContent();
        String[] split = djContent.split(",");
        for (String s : split) {
            JrAnswTwo jrAnswTwo = jrAnswTwoService.selectJrAnswTwoById(Integer.valueOf(s));
            Questions questions = questions1.get(i);
            questions.setXsAnswer(jrAnswTwo.getText());
            i++;
        }
        HashMap<Object, Object> map = new HashMap<>();
        ArrayList<Questions> list = new ArrayList<>();
        ArrayList<Questions> list1 = new ArrayList<>();
        ArrayList<Questions> list2 = new ArrayList<>();
        ArrayList<Questions> list3 = new ArrayList<>();

        for (Questions questions2 : questions1) {
            if ("1".equals(questions2.getQuestionType())) {
                list.add(questions2);//单选
            } else if ("2".equals((questions2.getQuestionType()))) {
                list1.add(questions2);//判断
            } else if ("3".equals(questions2.getQuestionType())) {
                list2.add(questions2);//多选
            } else if ("4".equals(questions2.getQuestionType())) {
                list3.add(questions2);//简答
            }
        }

        for (Questions questions : list) {
            if (StringUtil.isEmpty(questions.getXsAnswer()) || questions.getXsAnswer().equals("(null)")) {
                questions.setXsAnswer("");
            }
        }
        for (Questions questions : list1) {
            if (StringUtil.isEmpty(questions.getXsAnswer()) || questions.getXsAnswer().equals("(null)")) {
                questions.setXsAnswer("");
            }
        }

        for (Questions questions : list2) {
            if (StringUtil.isEmpty(questions.getXsAnswer()) || questions.getXsAnswer().equals("(null)")) {
                questions.setXsAnswer("");
            }
        }
        for (Questions questions : list3) {
            if (StringUtil.isEmpty(questions.getXsAnswer()) || questions.getXsAnswer().equals("(null)")) {
                questions.setXsAnswer("");
            }
        }

        map.put("fenshu", djScore);
        map.put("zongfen", b0);
        map.put("danxuan", list);
        map.put("panduan", list1);
        map.put("duoxuan", list2);
        map.put("jianda", list3);
        writeJSON(map, response, "200", "成功");

    }

    /**
     * 查询试卷详情(试题详情列表)
     *
     * @param response
     * @param request
     * @param paperId
     * @param type
     * @throws Exception
     */
    @ApiOperation("试题类型信息及答案")
    @GetMapping("/questiontypeList")
    @ResponseBody
    public void questiontypeList(HttpServletResponse response, HttpServletResponse request, Integer paperId, String type) throws Exception {
        log.info(LogUtil.LogInfo("查询试题列表", new Date()));
        List<Questions> questions1 = questionsService.selectByPaperId(paperId);

        HashMap<Object, Object> map = new HashMap<>();

        ArrayList<Questions> list = new ArrayList<>();
        ArrayList<Questions> list1 = new ArrayList<>();
        ArrayList<Questions> list2 = new ArrayList<>();
        ArrayList<Questions> list3 = new ArrayList<>();

        for (Questions questions : questions1) {
            if ("1".equals(questions.getQuestionType())) {
                list.add(questions);
            } else if ("2".equals((questions.getQuestionType()))) {
                list1.add(questions);
            } else if ("3".equals(questions.getQuestionType())) {
                list2.add(questions);
            } else if ("4".equals(questions.getQuestionType())) {
                list3.add(questions);
            }
        }

        map.put("danxuan", list);
        map.put("panduan", list1);
        map.put("duoxuan", list2);
        map.put("jianda", list3);

        writeJSON(map, response, "200", "成功");
    }

    /**
     * IOS端解析JSON字符串得到学生答案并保存
     */
    @PostMapping("/stanswer")
    @ResponseBody
    public void stanswer(HttpServletResponse response, PageBean pageBean1) throws Exception {

        PageBean pageBean = JSON.parseObject(pageBean1.getJson(), PageBean.class);

        List<PageBean.AnswerBean.DanxuanBean> danxuan = pageBean.getAnswer().getDanxuan();
        List<PageBean.AnswerBean.DuoxuanBean> duoxuan = pageBean.getAnswer().getDuoxuan();
        List<PageBean.AnswerBean.JiandaBean> jianda = pageBean.getAnswer().getJianda();
        List<PageBean.AnswerBean.PanduanBean> panduan = pageBean.getAnswer().getPanduan();

        StringBuilder stringBuilder = new StringBuilder();
        Answers answers = new Answers();
        StringBuilder str = null;
        BigDecimal b0 = new BigDecimal(0);
        Paper paper = paperService.selectPaperById(pageBean1.getPageid());

        ArrayList<String> list1 = new ArrayList<>();

        if (danxuan != null && danxuan.size() > 0) {
            for (PageBean.AnswerBean.DanxuanBean danxuanBean : danxuan) {

                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                String answer = danxuanBean.getAnswer();
                //得到试卷ID
                String stId = danxuanBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = danxuanBean.getQuestionType();
                jrAnswTwo.setText(answer);
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                Questions question = questionsService.selectQuestionsById(String.valueOf(danxuanBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案
                //将试题题号加上“，”，存入数据库中
                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String a = str.toString();
                list1.add(a);
                //计算分数
                if ("1".equals(question.getQuestionType())) {
                    String one = jrAnswTwo.getText();//考试答案
                    String two = stAnswer;//正确答案
                    if (StringUtils.isNotEmpty(one) && one.equals(two)) {
                        String s = StringUtil.isEmpty(paper.getSingleScore()) ? "0" : paper.getSingleScore();
                        b0 = b0.add(new BigDecimal(s));
                    }
                    continue;
                }
            }
        }


        if (duoxuan != null && duoxuan.size() > 0) {
            for (PageBean.AnswerBean.DuoxuanBean duoxuanBean : duoxuan) {
                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                List<String> list = duoxuanBean.getAnswer();
                //排序
                Collections.sort(list);
                StringBuilder stringBuilder1 = new StringBuilder();
                StringBuilder append = null;
                for (int i = 0; i < list.size(); i++) {
                    append = stringBuilder1.append(list.get(i) + ",");
//                    jrAnswTwo.setText(list.get(i));
                }
                String s1 = append.deleteCharAt(append.length() - 1).toString();
                jrAnswTwo.setText(s1);

                //得到试卷ID
                String stId = duoxuanBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = duoxuanBean.getQuestionType();

                //jrAnswTwo.setTextarray(duoxuanBean.getAnswer());
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String a = str.toString();

                Questions question = questionsService.selectQuestionsById(String.valueOf(duoxuanBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案
                //计算分数
                if ("3".equals(question.getQuestionType())) {
                    if (jrAnswTwo.getText() != null) {
                        String[] one = jrAnswTwo.getText().split(",");//考试答案
//                        List<String> strings = Arrays.asList(one);
//                        Collections.sort(strings);
//                        Object[] one1 = strings.toArray();
                        String[] two = stAnswer.split(",");//正确答案
                        Arrays.sort(one);
                        Arrays.sort(two);
                        if (one.length != two.length) continue;
                        if (Arrays.equals(one, two)) {
                            String s = StringUtils.isNull(paper) ? "0" : paper.getManyScore();
                            b0 = b0.add(new BigDecimal(s));
                        }
//                        for (int i = 0; i < one1.length; i++) {
//                            if (one1[i].equals(two[i])) {
//                                String s = StringUtils.isNull(paper) ? "0" : paper.getManyScore();
//                                b0 = b0.add(new BigDecimal(s));
//                            }
//                        }
                        continue;
                    }
                }
                list1.add(a);
            }
        }

        if (panduan != null && panduan.size() > 0) {
            for (PageBean.AnswerBean.PanduanBean panduanBean : panduan) {
                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                String answer = panduanBean.getAnswer();
                //得到试卷ID
                String stId = panduanBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = panduanBean.getQuestionType();

                jrAnswTwo.setText(answer);
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                Questions question = questionsService.selectQuestionsById(String.valueOf(panduanBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案

                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String a = str.toString();
                list1.add(a);
                if ("2".equals(question.getQuestionType())) {
                    String one = jrAnswTwo.getText();//考试答案
                    String two = stAnswer;//正确答案
                    if (StringUtils.isNotEmpty(one) && one.equals(two)) {
                        String s = StringUtil.isEmpty(paper.getJudgmentScore()) ? "0" : paper.getJudgmentScore();
                        b0 = b0.add(new BigDecimal(s));
                    }
                    continue;
                }
            }
        }

        if (jianda != null && jianda.size() > 0) {
            for (PageBean.AnswerBean.JiandaBean jiandaBean : jianda) {

                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                String answer = jiandaBean.getAnswer();
                //得到试卷ID
                String stId = jiandaBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = jiandaBean.getQuestionType();
                jrAnswTwo.setText(answer);
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                Questions question = questionsService.selectQuestionsById(String.valueOf(jiandaBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案
                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String s = str.toString();
                list1.add(s);
            }
        }

        //查询改试卷所有提交记录
        Answers answers3 = new Answers();
        answers3.setDjUserid(pageBean1.getUserid());
        answers3.setDjPaperid(pageBean1.getPageid());
        List<Answers> answers1 = answersService.selectByPaperId2(answers3);
        //得到最后一次提交的结束时间
        if (answers1.size() == 0) {
            int i = list1.size();
            String s = list1.get(i - 1);
            answers.setDjContent(s.substring(0, s.length() - 1));

            answers.setDjId(UUIDUtils.getByUUId());
            answers.setDjEndtime(new Date());
            answers.setDjPaperid(pageBean1.getPageid());
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Long startTime = pageBean1.getStartTime();
            Date parse = dateFormat.parse(dateFormat.format(startTime));
            answers.setDjStarttime(parse);
            answers.setDjUserid(pageBean1.getUserid());
            answers.setDjScore(b0);
            answersService.insertAnswers(answers);
            writeJSON(b0, response, "200", "success");
        } else {
            Answers answers2 = answers1.get(answers1.size() - 1);
            Date djEndtime = answers2.getDjEndtime();
            SimpleDateFormat dateForma = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Long starttime = pageBean1.getStartTime();
            Date parses = dateForma.parse(dateForma.format(starttime));

            //开始时间和上次的结束时间作差，大于1分钟才可提交，负责提示重复提交
            if (parses.getTime() - djEndtime.getTime() > 60000) {
                //去除题号最后的“，”，并存入数据库
                int i = list1.size();
                String s = list1.get(i - 1);
                answers.setDjContent(s.substring(0, s.length() - 1));

                answers.setDjId(UUIDUtils.getByUUId());
                answers.setDjEndtime(new Date());
                answers.setDjPaperid(pageBean1.getPageid());
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Long startTime = pageBean1.getStartTime();
                Date parse = dateFormat.parse(dateFormat.format(startTime));
                answers.setDjStarttime(parse);
                answers.setDjUserid(pageBean1.getUserid());
                answers.setDjScore(b0);
                answersService.insertAnswers(answers);
                writeJSON(b0, response, "200", "success");
            } else {
                writeJSON(null, response, "201", "重复提交");
            }
        }

    }

    /**
     * 安卓端解析JSON字符串得到学生答案并保存
     *
     * @param response
     * @param request
     * @param json
     * @throws Exception
     */
    @PostMapping("/stanswer1")
    @ResponseBody
    public void stanswer1(HttpServletResponse response, HttpServletRequest request, String json) throws Exception {

	/*	BufferedReader reader = request.getReader();
		char[] buf = new char[512];
		int len = 0;
		StringBuffer contentBuffer = new StringBuffer();
		while ((len = reader.read(buf)) != -1) {
			contentBuffer.append(buf, 0, len);
		}
		String content = contentBuffer.toString();
		if(content == null){
			content = "";
		}*/
        //System.out.println(json);
        PageBean pageBean = JSON.parseObject(json, PageBean.class);

        //String s = mPageBean.toString();

        List<PageBean.AnswerBean.DanxuanBean> danxuan = pageBean.getAnswer().getDanxuan();
        List<PageBean.AnswerBean.DuoxuanBean> duoxuan = pageBean.getAnswer().getDuoxuan();
        List<PageBean.AnswerBean.JiandaBean> jianda = pageBean.getAnswer().getJianda();
        List<PageBean.AnswerBean.PanduanBean> panduan = pageBean.getAnswer().getPanduan();

        StringBuilder stringBuilder = new StringBuilder();
        Answers answers = new Answers();
        StringBuilder str = null;
        BigDecimal b0 = new BigDecimal(0);
        Paper paper = paperService.selectPaperById(pageBean.getPageid());

        ArrayList<String> list1 = new ArrayList<>();

        if (danxuan != null && danxuan.size() > 0) {
            for (PageBean.AnswerBean.DanxuanBean danxuanBean : danxuan) {

                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                String answer = danxuanBean.getAnswer();
                //得到试卷ID
                String stId = danxuanBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = danxuanBean.getQuestionType();
                jrAnswTwo.setText(answer);
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                Questions question = questionsService.selectQuestionsById(String.valueOf(danxuanBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案
                //将试题题号加上“，”，存入数据库中
                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String a = str.toString();
                list1.add(a);
                //计算分数
                if ("1".equals(question.getQuestionType())) {
                    String one = jrAnswTwo.getText();//考试答案
                    String two = stAnswer;//正确答案
                    if (StringUtils.isNotEmpty(one) && one.equals(two)) {
                        String s = StringUtil.isEmpty(paper.getSingleScore()) ? "0" : paper.getSingleScore();
                        b0 = b0.add(new BigDecimal(s));
                    }
                    continue;
                }
            }
        }

        if (duoxuan != null && duoxuan.size() > 0) {
            for (PageBean.AnswerBean.DuoxuanBean duoxuanBean : duoxuan) {
                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                List<String> list = duoxuanBean.getAnswer();
                //排序
                Collections.sort(list);
                StringBuilder stringBuilder1 = new StringBuilder();
                StringBuilder append = null;
                for (int i = 0; i < list.size(); i++) {
                    append = stringBuilder1.append(list.get(i)).append(",");
//                    jrAnswTwo.setText(list.get(i));
                }
                if (StringUtils.isNotNull(append)) {
                    String s1 = append.deleteCharAt(append.length() - 1).toString();
                    jrAnswTwo.setText(s1);
                } else {
                    jrAnswTwo.setText("");
                }

                //得到试卷ID
                String stId = duoxuanBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = duoxuanBean.getQuestionType();

                //jrAnswTwo.setTextarray(duoxuanBean.getAnswer());
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String a = str.toString();

                Questions question = questionsService.selectQuestionsById(String.valueOf(duoxuanBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案
                //计算分数
                if ("3".equals(question.getQuestionType())) {
                    if (jrAnswTwo.getText() != null) {
                        String[] one = jrAnswTwo.getText().split(",");//考试答案
//                        List<String> strings = Arrays.asList(one);
//                        Collections.sort(strings);
//                        Object[] one1 = strings.toArray();
                        String[] two = stAnswer.split(",");//正确答案
                        Arrays.sort(one);
                        Arrays.sort(two);
                        if (one.length != two.length) continue;
                        if (Arrays.equals(one, two)) {
                            String s = StringUtils.isNull(paper) ? "0" : paper.getManyScore();
                            b0 = b0.add(new BigDecimal(s));
                        }
//                        for (int i = 0; i < one1.length; i++) {
//                            if (one1[i].equals(two[i])) {
//                                String s = StringUtils.isNull(paper) ? "0" : paper.getManyScore();
//                                b0 = b0.add(new BigDecimal(s));
//                            }
//                        }
                        continue;
                    }
                }
                list1.add(a);
            }
        }

        if (panduan != null && panduan.size() > 0) {
            for (PageBean.AnswerBean.PanduanBean panduanBean : panduan) {
                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                String answer = panduanBean.getAnswer();
                //得到试卷ID
                String stId = panduanBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = panduanBean.getQuestionType();

                jrAnswTwo.setText(answer);
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                Questions question = questionsService.selectQuestionsById(String.valueOf(panduanBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案

                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String a = str.toString();
                list1.add(a);
                if ("2".equals(question.getQuestionType())) {
                    String one = jrAnswTwo.getText();//考试答案
                    String two = stAnswer;//正确答案
                    if (StringUtils.isNotEmpty(one) && one.equals(two)) {
                        String s = StringUtil.isEmpty(paper.getJudgmentScore()) ? "0" : paper.getJudgmentScore();
                        b0 = b0.add(new BigDecimal(s));
                    }
                    continue;
                }
            }
        }

        if (jianda != null && jianda.size() > 0) {
            for (PageBean.AnswerBean.JiandaBean jiandaBean : jianda) {

                JrAnswTwo jrAnswTwo = new JrAnswTwo();
                //学生答案
                String answer = jiandaBean.getAnswer();
                //得到试卷ID
                String stId = jiandaBean.getStId();
                //得到试卷类型 1单选 2判断 3多选 4简单
                String questionType = jiandaBean.getQuestionType();
                jrAnswTwo.setText(answer);
                jrAnswTwo.setIsJD(questionType);
                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);

                Questions question = questionsService.selectQuestionsById(String.valueOf(jiandaBean.getId()));
                String stAnswer = question.getStAnswer();//正确答案
                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
                String s = str.toString();
                list1.add(s);
            }
        }

        //查询改试卷所有提交记录
        Answers answers3 = new Answers();
        answers3.setDjUserid(pageBean.getUserid());
        answers3.setDjPaperid(pageBean.getPageid());
        List<Answers> answers1 = answersService.selectByPaperId2(answers3);
        //得到最后一次提交的结束时间
        if (answers1.size() == 0) {
            int i = list1.size();
            String s = list1.get(i - 1);
            answers.setDjContent(s.substring(0, s.length() - 1));

            answers.setDjId(UUIDUtils.getByUUId());
            answers.setDjEndtime(new Date());
            answers.setDjPaperid(pageBean.getPageid());
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Long startTime = pageBean.getStartTime();
            Date parse = dateFormat.parse(dateFormat.format(startTime));
            answers.setDjStarttime(parse);
            answers.setDjUserid(pageBean.getUserid());
            answers.setDjScore(b0);
            answersService.insertAnswers(answers);
            writeJSON(b0, response, "200", "success");
        } else {
            Answers answers2 = answers1.get(answers1.size() - 1);
            Date djEndtime = answers2.getDjEndtime();
            SimpleDateFormat dateForma = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Long starttime = pageBean.getStartTime();
            Date parses = dateForma.parse(dateForma.format(starttime));

            //开始时间和上次的结束时间作差，大于1分钟才可提交，负责提示重复提交
            if (parses.getTime() - djEndtime.getTime() > 60000) {
                //去除题号最后的“，”，并存入数据库
                int i = list1.size();
                String s = list1.get(i - 1);
                answers.setDjContent(s.substring(0, s.length() - 1));

                answers.setDjId(UUIDUtils.getByUUId());
                answers.setDjEndtime(new Date());
                answers.setDjPaperid(pageBean.getPageid());
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Long startTime = pageBean.getStartTime();
                Date parse = dateFormat.parse(dateFormat.format(startTime));
                answers.setDjStarttime(parse);
                answers.setDjUserid(pageBean.getUserid());
                answers.setDjScore(b0);
                answersService.insertAnswers(answers);
                writeJSON(b0, response, "200", "success");
            } else {
                writeJSON(null, response, "201", "重复提交");
            }
        }

    }

//    /**
//     * 安卓端解析JSON字符串得到学生答案并保存
//     */
//    @PostMapping("/stanswer1")
//    @ResponseBody
//    public void stanswer1(HttpServletResponse response, HttpServletRequest request, String json) throws Exception {
//
//	/*	BufferedReader reader = request.getReader();
//		char[] buf = new char[512];
//		int len = 0;
//		StringBuffer contentBuffer = new StringBuffer();
//		while ((len = reader.read(buf)) != -1) {
//			contentBuffer.append(buf, 0, len);
//		}
//		String content = contentBuffer.toString();
//		if(content == null){
//			content = "";
//		}*/
//        //System.out.println(json);
//        PageBean pageBean = JSON.parseObject(json, PageBean.class);
//
//        //String s = mPageBean.toString();
//
//        List<PageBean.AnswerBean.DanxuanBean> danxuan = pageBean.getAnswer().getDanxuan();
//        List<PageBean.AnswerBean.DuoxuanBean> duoxuan = pageBean.getAnswer().getDuoxuan();
//        List<PageBean.AnswerBean.JiandaBean> jianda = pageBean.getAnswer().getJianda();
//        List<PageBean.AnswerBean.PanduanBean> panduan = pageBean.getAnswer().getPanduan();
//
//        StringBuilder stringBuilder = new StringBuilder();
//        Answers answers = new Answers();
//        StringBuilder str = null;
//        BigDecimal b0 = new BigDecimal(0);
//        Paper paper = paperService.selectPaperById(pageBean.getPageid());
//
//        ArrayList<String> list1 = new ArrayList<>();
//
//        if (danxuan != null && danxuan.size() > 0) {
//            for (PageBean.AnswerBean.DanxuanBean danxuanBean : danxuan) {
//
//                JrAnswTwo jrAnswTwo = new JrAnswTwo();
//                //学生答案
//                String answer = danxuanBean.getAnswer();
//                //得到试卷ID
//                String stId = danxuanBean.getStId();
//                //得到试卷类型 1单选 2判断 3多选 4简单
//                String questionType = danxuanBean.getQuestionType();
//                jrAnswTwo.setText(answer);
//                jrAnswTwo.setIsJD(questionType);
//                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);
//
//                Questions question = questionsService.selectQuestionsById(String.valueOf(danxuanBean.getId()));
//                String stAnswer = question.getStAnswer();//正确答案
//                //将试题题号加上“，”，存入数据库中
//                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
//                String a = str.toString();
//                list1.add(a);
//                //计算分数
//                if ("1".equals(question.getQuestionType())) {
//                    String s = StringUtils.isNull(paper) ? "0" : paper.getSingleScore();
//                    b0 = b0.add(new BigDecimal(s));
//                    continue;
//                }
//            }
//        }
//
//        if (duoxuan != null && duoxuan.size() > 0) {
//            for (PageBean.AnswerBean.DuoxuanBean duoxuanBean : duoxuan) {
//                JrAnswTwo jrAnswTwo = new JrAnswTwo();
//                //学生答案
//                List<String> list = duoxuanBean.getAnswer();
//
//                for (int i = 0; i < list.size(); i++) {
//                    jrAnswTwo.setText(list.get(i));
//                }
//                //得到试卷ID
//                String stId = duoxuanBean.getStId();
//                //得到试卷类型 1单选 2判断 3多选 4简单
//                String questionType = duoxuanBean.getQuestionType();
//
//                //jrAnswTwo.setTextarray(duoxuanBean.getAnswer());
//                jrAnswTwo.setIsJD(questionType);
//                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);
//
//                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
//                String a = str.toString();
//
//                Questions question = questionsService.selectQuestionsById(String.valueOf(duoxuanBean.getId()));
//                String stAnswer = question.getStAnswer();//正确答案
//                //计算分数
//                if ("3".equals(question.getQuestionType())) {
//                    if (jrAnswTwo.getText() != null) {
//                        String[] one = jrAnswTwo.getText().split(",");//考试答案
//                        String[] two = stAnswer.split(",");//正确答案
//                        if (one.length != two.length) continue;
//                        for (int i = 0; i < one.length; i++) {
//                            if (one[i].equals(two[i])) {
//                                String s = StringUtils.isNull(paper) ? "0" : paper.getSingleScore();
//                                b0 = b0.add(new BigDecimal(s));
//                            }
//                        }
//                        continue;
//                    }
//                }
//                list1.add(a);
//            }
//        }
//
//        if (panduan != null && panduan.size() > 0) {
//            for (PageBean.AnswerBean.PanduanBean panduanBean : panduan) {
//                JrAnswTwo jrAnswTwo = new JrAnswTwo();
//                //学生答案
//                String answer = panduanBean.getAnswer();
//                //得到试卷ID
//                String stId = panduanBean.getStId();
//                //得到试卷类型 1单选 2判断 3多选 4简单
//                String questionType = panduanBean.getQuestionType();
//
//                jrAnswTwo.setText(answer);
//                jrAnswTwo.setIsJD(questionType);
//                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);
//
//                Questions question = questionsService.selectQuestionsById(String.valueOf(panduanBean.getId()));
//                String stAnswer = question.getStAnswer();//正确答案
//
//                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
//                String a = str.toString();
//                list1.add(a);
//                if ("2".equals(question.getQuestionType())) {
//                    String s = StringUtils.isNull(paper) ? "0" : paper.getSingleScore();
//                    b0 = b0.add(new BigDecimal(s));
//                    continue;
//                }
//            }
//        }
//
//        if (jianda != null && jianda.size() > 0) {
//            for (PageBean.AnswerBean.JiandaBean jiandaBean : jianda) {
//
//                JrAnswTwo jrAnswTwo = new JrAnswTwo();
//                //学生答案
//                String answer = jiandaBean.getAnswer();
//                //得到试卷ID
//                String stId = jiandaBean.getStId();
//                //得到试卷类型 1单选 2判断 3多选 4简单
//                String questionType = jiandaBean.getQuestionType();
//                jrAnswTwo.setText(answer);
//                jrAnswTwo.setIsJD(questionType);
//                jrAnswTwoService.insertJrAnswTwo(jrAnswTwo);
//
//                Questions question = questionsService.selectQuestionsById(String.valueOf(jiandaBean.getId()));
//                String stAnswer = question.getStAnswer();//正确答案
//                str = stringBuilder.append(jrAnswTwo.getId()).append(",");
//                String s = str.toString();
//                list1.add(s);
//            }
//        }
//
//        //查询改试卷所有提交记录
//
//        Answers answers3 = new Answers();
//        answers3.setDjUserid(pageBean.getUserid());
//        answers3.setDjPaperid(pageBean.getPageid());
//        List<Answers> answers1 = answersService.selectByPaperId2(answers3);
//        //得到最后一次提交的结束时间
//        if (answers1.size() == 0) {
//            int i = list1.size();
//            String s = list1.get(i - 1);
//            answers.setDjContent(s.substring(0, s.length() - 1));
//
//            answers.setDjId(UUIDUtils.getByUUId());
//            answers.setDjEndtime(new Date());
//            answers.setDjPaperid(pageBean.getPageid());
//            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            Long startTime = pageBean.getStartTime();
//            Date parse = dateFormat.parse(dateFormat.format(startTime));
//            answers.setDjStarttime(parse);
//            answers.setDjUserid(pageBean.getUserid());
//            answers.setDjScore(b0);
//            answersService.insertAnswers(answers);
//            writeJSON(b0, response, "200", "success");
//        } else {
//            Answers answers2 = answers1.get(answers1.size() - 1);
//            Date djEndtime = answers2.getDjEndtime();
//            SimpleDateFormat dateForma = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            Long starttime = pageBean.getStartTime();
//            Date parses = dateForma.parse(dateForma.format(starttime));
//
//            //开始时间和上次的结束时间作差，大于1分钟才可提交，负责提示重复提交
//            if (parses.getTime() - djEndtime.getTime() > 60000) {
//                //去除题号最后的“，”，并存入数据库
//                int i = list1.size();
//                String s = list1.get(i - 1);
//                answers.setDjContent(s.substring(0, s.length() - 1));
//
//                answers.setDjId(UUIDUtils.getByUUId());
//                answers.setDjEndtime(new Date());
//                answers.setDjPaperid(pageBean.getPageid());
//                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                Long startTime = pageBean.getStartTime();
//                Date parse = dateFormat.parse(dateFormat.format(startTime));
//                answers.setDjStarttime(parse);
//                answers.setDjUserid(pageBean.getUserid());
//                answers.setDjScore(b0);
//                answersService.insertAnswers(answers);
//                writeJSON(b0, response, "200", "success");
//            } else {
//                writeJSON(null, response, "201", "重复提交");
//            }
//        }
//
//    }

    /**
     * 用户试卷答题,将答案存入数据库，键值对传入
     */
    @GetMapping("/answers")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "djPaperid", value = "试卷编号", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "djUserid", value = "答题者Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "djQuestionsids", value = "答题ID", required = true, dataType = "String"),
            @ApiImplicitParam(name = "djAnswers", value = "答题内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "djStarttime", value = "开始时间", required = true, dataType = "Date")})
    public void answers(HttpServletResponse response,
                        Integer djPaperid,
                        String djUserid,
                        String djAnswers,
                        String djStarttime) throws Exception {
        BigDecimal b0 = new BigDecimal(0);
        Paper paper = paperService.selectPaperById(djPaperid);
        if (paper != null) {
            List<JrAnswTwo> twoList = JSONObject.parseArray(djAnswers, JrAnswTwo.class);
            StringBuilder stringBuilder = new StringBuilder();
            StringBuilder str = null;
            for (JrAnswTwo jrAnswTwo : twoList) {
                JrAnswTwo answTwo = new JrAnswTwo();
                answTwo.setText(jrAnswTwo.getText());
                answTwo.setIsJD(jrAnswTwo.getIsJD());
                jrAnswTwoService.insertJrAnswTwo(answTwo);
                str = stringBuilder.append(answTwo.getId()).append(",");
                //1 单选 2 判断 3 多选 4 简答
                Questions question = questionsService.selectQuestionsById(jrAnswTwo.getId().toString());
                String stAnswer = question.getStAnswer();//正确答案
                if ("4".equals(question.getQuestionType())) continue;
                if ("3".equals(question.getQuestionType())) {
                    String[] one = jrAnswTwo.getText().split(",");//考试答案
                    String[] two = stAnswer.split(",");//正确答案
                    if (one.length != two.length) continue;
                    for (int i = 0; i < one.length; i++) {
                        if (one[i].equals(two[i])) {
                            String s = StringUtil.isEmpty(paper.getManyScore()) ? "0" : paper.getManyScore();
                            b0 = b0.add(new BigDecimal(s));
                        }
                    }
                    continue;
                }
                if ("2".equals(question.getQuestionType())) {
                    String s = StringUtil.isEmpty(paper.getJudgmentScore()) ? "0" : paper.getJudgmentScore();
                    b0 = b0.add(new BigDecimal(s));
                    continue;
                }
                if ("1".equals(question.getQuestionType())) {
                    String s = StringUtil.isEmpty(paper.getSingleScore()) ? "0" : paper.getSingleScore();
                    b0 = b0.add(new BigDecimal(s));
                    continue;
                }
            }
            Answers answer = new Answers();
            answer.setDjId(UUIDUtils.getByUUId());
            answer.setDjEndtime(new Date());
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date strtodate = formatter.parse(djStarttime);
            answer.setDjStarttime(strtodate);
            String s = str.toString();
            answer.setDjContent(s.substring(0, s.length() - 1));
            answer.setDjPaperid(djPaperid);
            answer.setDjScore(b0);
            answer.setDjUserid(djUserid);
            answersService.insertAnswers(answer);
        }
        writeJSON(b0, response, "200", "成功");
    }

    /**
     * 查询试题列表
     */
    @ApiOperation("试题答案信息")
    @GetMapping("/questionsAnsList")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "paperId", value = "试卷编号", required = true, dataType = "String"),
            @ApiImplicitParam(name = "djId", value = "试题编号", required = true, dataType = "String"),

    })
    public void questionsAnsList(HttpServletResponse response, HttpServletRequest request, String paperId, String djId) throws Exception {
        log.info(LogUtil.LogInfo("查询试题答案列表", new Date()));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("paperId", paperId);
        List<QuestionsVo> list = questionsService.selectQuestionsListById(map);
        int count = questionsService.selectCount(map);
        Answers answers = answersService.selectAnswersById(djId);
        Map<String, Object> map1 = new HashMap<String, Object>();
        String djContent = answers.getDjContent();//答题内容
        String[] conntents = djContent.split(",");
        if (conntents.length == list.size()) {//答案数量和试题数量一致时 把答案设置到试题返回
            for (int i = 0; i < list.size(); i++) {
                String content = conntents[i];
                list.get(i).setZqString(content);
            }
            map1.put("count", count);
            map1.put("list", list);
            writeJSON(map1, response, "200", "成功");
        }

    }
}


